<?php

use common\widgets\ic\qiniu\QiniuUpload;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\Banner */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="banner-form">

    <?php $form = ActiveForm::begin([
        'options' => ['class' => 'form-horizontal'],
        'fieldConfig' => [
            'options' => ['class' => 'form-group'],
            'template' => "{label}\n<div class=\"col-sm-8\">{input}\n<span class=\"help-block m-b-none\">{error}</span></div><div class='col-sm-8 col-sm-offset-2'>{hint}</div>",
            'labelOptions' => ['class' => 'col-sm-2 control-label'],
        ]
    ]); ?>
    <?= $form->field($model, 'category_id')->dropDownList(
        \yii\helpers\ArrayHelper::map(
            \common\models\Category::makeCategory(\common\models\Category::find()
                ->all()
            ),'id','name')
    ) ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
    <?= $form->field($model, 'image')->widget(\common\widgets\cos\CosWidget::class, [
        'uploadUrl' => Yii::$app->params['cos']['uploadUrl'],
        'clientOptions' => [
            'max' => 1
        ]
    ])->hint("支持格式：image/jpeg,image/gif,image/png；(最多上传一张)") ?>

    <?= $form->field($model, 'is_hot')->dropDownList([0 => "否", 1 => "是"]) ?>
    <?= $form->field($model, 'is_search')->dropDownList([0 => "否", 1 => "是"]) ?>
    <div class="form-group">
        <div class="col-sm-4 col-sm-offset-2">
            <?= Html::submitButton($model->isNewRecord ? '保存' : '保存', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
        </div>
    </div>

    <?php ActiveForm::end(); ?>

</div>
